<?php

namespace app\admin\controller;

use app\common\controller\BasicAdmin;
use app\common\traits\SelectPage;

class CourseComment extends BasicAdmin
{
    use SelectPage;
    protected $model = 'CourseCommentModel';

    public function index(){
        $this->title = '评论管理';
        return $this->_query($this->model)
            ->join('edu_course c','edu_course_comment.course_id=c.id','left')
            ->join('edu_user u','edu_course_comment.user_id=u.id','left')
            ->where(function ($db){
                if($this->request->has('course_id','get') && !empty($this->request->get('course_id'))){
                    $course_id = $this->request->get('course_id');
                    $db->where('edu_course_comment.course_id', $course_id);
                }
            })
            ->field('edu_course_comment.*,c.name AS course_name,u.realname AS user_name')
            ->page();
    }

    public function del(){
//        $id = input('id');
        $this->_delete($this->model);
    }

}